package com.sakuraio.nextj.core.protocol.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.NumberSerializers;

import java.io.IOException;

/**
 * @author nekoimi 2024/1/2 11:12
 */
public class LongToIntSerializer extends NumberSerializers.Base<Long> {

    public LongToIntSerializer() {
        super(Long.class, JsonParser.NumberType.LONG, "integer");
    }

    @Override
    public void serialize(Long value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeNumber(value.intValue());
    }
}
